import scrapy


class XUserSpider(scrapy.Spider):
    name = 'x_user_scraper'

    def start_requests(self):
        # 初始请求必须使用 Playwright 以执行 JS 并获取令牌
        # user_timeline_url = 'https://x.com/target_user_handle'
        user_timeline_url = 'https://x.com/kitti3miti'
        yield scrapy.Request(
            url=user_timeline_url,
            callback=self.parse_tokens_and_initial_data,
            meta={
                "playwright": True,  # 启用 Playwright
                "playwright_include_page": True  # 允许访问 Page 对象进行交互或拦截
            }
        )